package com.sgb.member.ui.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sgb.member.BR;
import com.sgb.member.MemberConfig;
import com.sgb.member.R;
import com.sgb.member.entity.MemberIntellectualPropertyBean;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.MToast;

import java.util.List;

/**
 * Created by：冯齐 on 2021/1/27 17:11
 * Description：
 */
public class IntellectualPropertyAdapter extends BaseRecycleAdapter<MemberIntellectualPropertyBean> {

    public IntellectualPropertyAdapter(Context context, List<MemberIntellectualPropertyBean> datas) {
        super(context, R.layout.item_intellectual_property, datas);
    }

    @SuppressLint("CheckResult")
    @Override
    public void convert(ItemViewHolder holder, final MemberIntellectualPropertyBean entity) {
        holder.setBinding(BR.viewModel, entity);
        TextView propertText = holder.itemView.findViewById(R.id.propert_text);
        LinearLayout enterEnterprise = holder.itemView.findViewById(R.id.enter_enterprise);//进入企业
        // 专利类型 ｜领域类型｜专利状态
        if ("专利".equals(entity.getTypesOfPropertyRights())) {
            if ("2".equals(entity.getState())) {
                propertText.setText(String.format("%s | %s | 授权已下发", entity.getFieldClassName(), entity.getType()));
            } else {
                propertText.setText(String.format("%s | %s | 授权未下发", entity.getFieldClassName(), entity.getType()));
            }
        } else {
            propertText.setText(entity.getType());
        }
        enterEnterprise.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!TextUtils.isEmpty(entity.getCompanyNo())) {
                    MemberConfig.getInstance().startWebsiteInfo(context, entity.getCompanyNo(), 1);
                } else {
                    MToast.showToast(context, "店铺No为空");
                }
            }
        });
    }
}
